<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/common.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<meta charset="utf-8">
<head></head>
<body class="gray-bg">

	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								税种：
								<input type="text" name="declarationTaxType" />
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()">
									<i class="fa fa-search"></i>
									&nbsp;搜索
								</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()">
									<i class="fa fa-refresh"></i>
									&nbsp;重置
								</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="doAdd()"  >
					<i class="fa fa-plus"></i>
					添加
				</a>
			<!-- 	<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:taxDeclaration:edit">
					<i class="fa fa-edit"></i>
					修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:taxDeclaration:remove">
					<i class="fa fa-remove"></i>
					删除
				</a> -->
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	<script th:inline="javascript">
		var prefix = "${ctx}/system/declaration";
	
		$(function() {
			var options = {
				url : prefix + "/list",
				createUrl : prefix + "/infoList",
				updateUrl : prefix + "/edit/{id}",
				removeUrl : prefix + "/remove",
				exportUrl : prefix + "/export",
				modalName : "纳税申报",
				search : false,
				showColumns : false,
				showToggle : false,
				columns : [ {
					checkbox : true
				},
					{
						field : 'declarationId',
						title : '',
						visible : false
					},
                    {
                        field : 'owner',
                        title : '纳税人',
                    },
                    {
                        field : 'company',
                        title : '所属公司',
                    },
					{
						field : 'declarationTaxType',
						title : '税种',
					},
					{
						field : 'declarationTaxModel',
						title : '税目',
					},
					{
						field : 'declarationTaxProject',
						title : '应纳税项目',
					},
					{
						field : 'declarationTaxRate',
						title : '适用税率',
					},
					{
						field : 'declarationTaxBasis',
						title : '计税依据',
					},
					{
						field : 'declarationTaxCondition',
						title : '扣除项目及标准',
                        width:'200'
					},
					{
						field : 'declarationTaxMoney',
						title : '应纳税额',
					},
					{
						field : 'declarationReplaceMoney',
						title : '代收代缴税额',
					},
					{
						field : 'declarationTaxTime',
						title : '税款所属期限',
					}, {
						field : 'status',
						title : '状态',
						formatter : function(value, row, index) {
							if (row.status == 1) {
								return "已创建";
							} else if (row.status == 2) {
								return "审核中";
							} else if (row.status == 3) {
								return "不通过";
							} else {
								return "审核通过";
							}
						}
					},
					{
						title : '操作',
						align : 'center',
						formatter : function(value, row, index) {
							var actions = [];
							if (row.status == 1) {
								actions.push('<a class="btn btn-info btn-xs" href="#" onclick="$.operate.edit(\'' + row.declarationId + '\')"><i class="fa fa-submit"></i>编辑</a>');
								actions.push('<a class="btn btn-info btn-xs" href="#" onclick="doSubmit(\'' + row.declarationId + '\')"><i class="fa fa-submit"></i>提交审核</a>');
							}
							if (row.status != 4) {
								actions.push('<a class="btn btn-danger btn-xs" href="#" onclick="$.operate.remove(\'' + row.declarationId + '\')"><i class="fa fa-remove"></i>删除</a>');
							}
							return actions.join('');
						}
					} ]
			};
			$.table.init(options);
		});
	
		function doSubmit(id) {
			if (confirm("你确定提交审核？")) {
				$.post(prefix + "/submitFlow", {
					declarationId : id
				}, function(data) {
					$.operate.ajaxSuccess(data);
				});
			}
		}

		function doAdd() {
            $.modal.loading("正在处理中，请稍后...");
            $.modal.disable();
			window.location.href=prefix + "/infoList"
        }

	</script>
</body>
</html>